<?php 
// 登录页面
include 'comm.php';
    if (isset($_POST['submit'])){
       //登录
        if($_SESSION['code']!=$_POST['code']){
            show_msg("验证码错误！","login.php");
        }else {
            login($_POST['username'],md5($_POST['pw']),$_SESSION['code']);
        }
    }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML>
<HEAD>
<TITLE>用户登录</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<STYLE type=text/css>BODY {
	MARGIN: 0px
}
</STYLE>
<LINK href="css/css.css" type=text/css rel=stylesheet>
<STYLE type=text/css>.STYLE1 {
	FONT-FAMILY: "宋体"
}
</STYLE>
<script src="jquery-3.4.1.js"></script>
<script type="text/javascript">
	function check(){
		if(myform.username.value==""){
			alert("用户名不能为空");
			return false;
		}
		if(myform.pw.value==""){
			alert("密码不能为空");
			return false;
		}
		if(myform.code.value==""){
			alert("验证码不能为空");
			return false;
		}
		if(document.getElementById("u_check").innerHTML=="用户名已经被占用！"){
// 			alert("用户名已经被占用！");
			return false;
		}
		return true;
	};

	function flush_code(){
		document.getElementById("img_code").src="yzm.php?"+Math.random();
	};
	
</script>
<META content="MSHTML 6.00.2900.6003" name=GENERATOR>
</HEAD>
<BODY>
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
  <TBODY>
  <TR>
    <TD
    style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid"
    vAlign=top width=140 bgColor=#eeeeee>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD class=left_bg2><A class=link3
            href="register.php">用户注册</A></TD></TR>
        <TR>
          <TD class=left_bg2><A class=link3
            href="login.php">用户登录</A></TD></TR>
        <TR>
        <TR>
          <TD class=left_bg2><A class=link3
            href="view.php">查看留言</A></TD></TR>
        <TR>
          <TD class=left_bg2><A class=link3
            href="lyb.php">在线留言</A></TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD></TD></TR></TBODY></TABLE></TD>
    <TD vAlign=top width=8></TD>
    <TD vAlign=top>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD class=bt>用户登录</TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=0 cellPadding=10 width="100%" border=0>
        <TBODY>
        <TR>
          <TD height=350>
            <TABLE cellSpacing=1 cellPadding=6 width="100%" bgColor=#ff9900
            border=0>
              <TBODY>
              <TR>
                <TD
                bgColor=#fff2e6>欢迎您登录本论坛</TD></TR></TBODY></TABLE><BR>
        <FORM id=myform name=myform action="" method=post onsubmit="return check();">
            <TABLE borderColor=#111111 cellSpacing=0 cellPadding=4 width="100%" bgColor=#ffffff border=0>
              
                  <TBODY>
                      <TR>
                        <TD vAlign=bottom noWrap colSpan=2></TD></TR>
                      <TR>
                        <TD vAlign=bottom width=65>用户：</TD>
                        <TD vAlign=bottom><INPUT id=username name=username> *<span id="u_check" style="color: red"></span> </TD></TR>
                      <TR>
                        <TD vAlign=bottom width=65>密码：</TD>
                        <TD vAlign=bottom><INPUT id=pw name=pw type="password"> * </TD></TR>
                      <TR>
                        <TD vAlign=bottom width=65>验证码：</TD>
                        <TD vAlign=bottom><INPUT id=code name=code><img id="img_code" src="yzm.php" height=20 onclick="flush_code()" /></TD></TR>
                      <TR>
                        <TD rowSpan=2>
          					<input type="submit" name="submit" value="登录"/>
          				</TD>
          				<TD rowSpan=2>
          				    <input type="reset" name="reset" value="重置"/>
                        </TD>
                      </TR>
                 </TBODY>
          </TABLE>
       </FORM>
              </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</BODY>   
</HTML>
